#include <bits/stdc++.h>
using namespace std;
#define int long long
int mod=1e9+7;
unordered_map<int, int>m;
int qpow(int x,int n)
{
    if(m[n])return m[n];
    int ret=1;
    while(n)
    {
        if(n&1)ret=ret*x%mod;
        x=x*x%mod;
        n>>=1;
    }
    m[n]=ret;
    return ret;
}
void solve()
{
    int n;
    cin>>n;
    vector<int>v(n+1);
    unordered_map<int, int>mp;
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        cin>>v[i];
        ++mp[v[i]];
    }
    int c=0;
    for(auto x:mp)
    {
        if(x.first)ans=(ans+qpow(2,x.second)-1)%mod;
    }
    int z=1;
    while(mp[c])
    {
        z=z*(qpow(2,mp[c])-1)%mod;
        ans=(ans+z)%mod;
        c++;
    }
    cout<<ans;
}
signed main()
{
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    int T=1;
    //cin>>T;
    while(T--)
    {
       solve();
    }
    return 0;
}